﻿using System;
using System.Text.RegularExpressions;

namespace Util {
    public  static class Tools {
        public static string ArrangeProfileName(string input) {
            string regexSearch = new string(System.IO.Path.GetInvalidFileNameChars())
                + new string(System.IO.Path.GetInvalidPathChars());
            Regex r = new Regex(string.Format("[{0}]", Regex.Escape(regexSearch)));
            return r.Replace(input.Trim().Replace("\\", "_").Replace("/", "_"), "_");
        }
    }
    class Encoding {
        static public string EncodeTo64(string toEncode) {
            return System.Convert.ToBase64String(System.Text.ASCIIEncoding.UTF8.GetBytes(toEncode));
        }
        static public string DecodeFrom64(string encodedData) {
            return System.Text.ASCIIEncoding.UTF8.GetString(Convert.FromBase64String(encodedData));
        }
    }
}
